/**
 * Project Name:shiro_not_sql
 * File Name:LoginService.java
 * Package Name:cn.wind.service
 * Date:2015年11月25日下午2:47:08
 *
*/

package cn.wind.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.wind.po.SysPermission;
import cn.wind.po.SysUser;

/**
 * ClassName:LoginService <br/>
 * Function: 模拟从数据库取数据. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2015年11月25日 下午2:47:08 <br/>
 * @author   LILANDONG
 * @version  
 * @since    JDK 1.7
 * @see 	 
 */
@Service
public class LoginServiceImpl implements LoginService{
	public SysUser getUserByUserName(String name){
		SysUser sysUser = new SysUser();
		if(name=="lld"||"lld".equals(name)){
			sysUser.setId("1");
			sysUser.setPassword("553e83ca69693b33ef73958c04b7a315");//明文是123.md5，1次散列是553e83ca69693b33ef73958c04b7a315
			sysUser.setSalt("qwer");
			sysUser.setUsercode(name);
			sysUser.setUsername("李兰东");
		}
		if(name=="zyhh"||"zyhh".equals(name)){
			sysUser.setId("2");
			sysUser.setPassword("6572bdaff799084b973320f43f09b363");//明文是123.md5，1次散列是6572bdaff799084b973320f43f09b363
			sysUser.setSalt("asdf");
			sysUser.setUsercode(name);
			sysUser.setUsername("赵业皓涵");
		}
		return sysUser;
	}
	public List<SysPermission> getMenusByUserId(String userId){
		List<SysPermission> menus = new ArrayList<SysPermission>();
		if(userId=="1"||"1".equals(userId)){
			SysPermission sysPermission = new SysPermission();
			sysPermission.setAvailable("1");
			sysPermission.setId(Long.valueOf(11));
			sysPermission.setName("商品管理");
			sysPermission.setType("menu");
			sysPermission.setUrl("item/itempage.do");
			sysPermission.setParentid(Long.valueOf(1));
			sysPermission.setParentids("0/1/");
			sysPermission.setPercode("item:query");
			sysPermission.setSortstring("1.");
			menus.add(sysPermission);
		}
		if(userId=="2"||"2".equals(userId)){
			SysPermission sysPermission = new SysPermission();
			sysPermission.setAvailable("1");
			sysPermission.setId(Long.valueOf(11));
			sysPermission.setName("商品管理");
			sysPermission.setType("menu");
			sysPermission.setUrl("item/itempage.do");
			sysPermission.setParentid(Long.valueOf(1));
			sysPermission.setParentids("0/1/");
			sysPermission.setPercode("item:query");
			sysPermission.setSortstring("1.");
			menus.add(sysPermission);
		}
		return menus;
	}
	@Override
	public List<String> permissions(String userId) {
		List<String> permissions = new ArrayList<String>();
		if(userId=="1"||"1".equals(userId)){
			permissions.add("item:query");
		}
		if(userId=="2"||"2".equals(userId)){
			permissions.add("item:add");
			permissions.add("item:update");
		}
		return permissions;
	}
}

